package com.nzw.service.impl.shop;


import com.nzw.pojo.shop.Shop;
import com.nzw.service.impl.common.BaseServiceImpl;
import com.nzw.service.shop.ShopService;
import com.nzw.vo.common.HttpResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;

/**
 * Created by Administrator on 2017/12/28/028.
 */
@Service
public class ShopServiceImpl extends BaseServiceImpl implements ShopService {

    @Autowired
    HttpSession httpSession;


    @Override
    public HttpResult deleteShopById(Long id) {

        Shop shop = getEntityById(id,Shop.class);
        shop.setDel(true);
        return new HttpResult(HttpResult.OK, updateEntityValues(shop));
    }

    @Override
    public HttpResult addShop(Shop shop) {
        shop.setDel(false);
        return new HttpResult(HttpResult.OK,addEntity(shop));
    }

    @Override
    public Shop getShopByAppId(String appid) {

        return getEntityByOneProperty(Shop.class,"appid",appid);
    }

//    @Override
    public HttpResult loginShop(String name, String pwd) {
//
//            Map<String,Object> map = new HashMap<String,Object>();
//
//
//            Shop shop = getEntityByOneProperty(Shop.class,"userName",name);
//            if(shop != null){
////                if(shop.getPassword().equals(pwd)){
////                    map.put("state",true);
////                    httpSession.setAttribute("shopId",shop.getId());
////                    return new HttpResult(HttpResult.OK,map);
////                }else{
////                    map.put("state",false);
////                    map.put("msg","密码不正确，请重新输入");
////                    return new HttpResult(HttpResult.OK,map);
////
////                }
//
//            }else{
//                map.put("state",false);
//                map.put("msg","登录名称错误");
//                return new HttpResult(HttpResult.OK,map);
//            }
//
//

        return null;
    }



    @Override
    public HttpResult updateShop(Shop shop) {
        shop.setDel(false);
        return new HttpResult(HttpResult.OK, updateEntityValues(shop));
    }


    @Override
    public Shop getShopById(Long id) {
        return getEntityById(id,Shop.class);
    }
}
